package com.dayang.schedule;


import java.io.Serializable;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;



@Service("redisUtil")
public class RedisUtil {
	
	public static Logger logger = LogManager.getLogger(RedisUtil.class);
	
	/*@Autowired
	public RedisTemplate<Serializable, Object> redisTemplate; 
	
	
	
	 *//** 
     * 判断缓存中是否有对应的value 
     *  
     * @param key 
     * @return 
     *//*  
    public boolean exists(final String key) {  
        return redisTemplate.hasKey(key);  
    }  
	
	
	
    *//** 
     * 删除对应的value 
     *  
     * @param key 
     *//*  
    public void remove(final String key) {  
        if (exists(key)) {  
            redisTemplate.delete(key);  
        }  
    }  
	
	
    *//** 
     * 读取缓存 
     *  
     * @param key 
     * @return 
     *//*  
    public Object get(final String key) {  
        Object result = null;  
        ValueOperations<Serializable, Object> operations = redisTemplate  
                .opsForValue();  
        result = operations.get(key);  
        return result;  
    }  
  
    *//** 
     * 写入缓存 
     *  
     * @param key 
     * @param value 
     * @return 
     *//*  
    public boolean set(final String key, Object value) {  
        boolean result = false;  
        try {  
            ValueOperations<Serializable, Object> operations = redisTemplate  
                    .opsForValue(); 
            operations.set(key, value);  
            result = true;  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return result;  
    }

    *//**
     * @return
     *//*
    public String flushDB() {
        return redisTemplate.execute(new RedisCallback() {
            public String doInRedis(RedisConnection connection) throws DataAccessException {
                connection.flushAll();
                return "ok";
            }
        });
    }

	public RedisTemplate<Serializable, Object> getRedisTemplate() {
		return redisTemplate;
	}



	public void setRedisTemplate(RedisTemplate<Serializable, Object> redisTemplate) {
		this.redisTemplate = redisTemplate;
	}  
	
	*/
	

}
